﻿Imports System.Data
Imports System.Data.SqlClient
Public Class UnidadMedidaDatos

    Function obtenerUnidadesMedida() As DataTable
        Dim dt As New DataTable
        Dim ds As New DataSet
        Dim conex As New Conexion
        Dim con As SqlConnection = conex.conectar

        Try
            con.Open()

            Dim query As String = "SELECT UNM_Codigo, UNM_Abreviatura " &
                                  "FROM UnidadMedida " &
                                  "WHERE UNM_Activo = '1'"

            Dim adapter As New SqlDataAdapter(query, con)
            adapter.Fill(ds)

            dt = ds.Tables(0)
            Dim row As DataRow = dt.NewRow()
            row.Item("UNM_Codigo") = 0
            row.Item("UNM_Abreviatura") = "Seleccionar..."
            dt.Rows.InsertAt(row, 0)
        Catch ex As Exception
            dt = Nothing
        End Try

        Return dt
    End Function

End Class
